let port = (self.port = document.getElementById("uas-port"));
const id = (Math.random() + 1).toString(36).substring(7),
  override = (t) => {
    port.dispatchEvent(
      new CustomEvent("override", { detail: { id: id, reason: t } })
    );
  };
if (port) (port.dataset.id = id), port.remove();
else {
  const t = [];
  let [e, r] = [parent, self];
  for (;;) {
    for (let a = 0; a < e.frames.length; a += 1)
      e.frames[a] === r && t.unshift(a);
    if (e.port) {
      (port = e.port),
        "true" !== port.dataset.disabled &&
          port.dispatchEvent(
            new CustomEvent("register", { detail: { id: id, hierarchy: t } })
          );
      break;
    }
    if ((([r, e] = [e, e.parent]), r === e)) break;
  }
}
if (port)
  if (port.dataset.str) "true" !== port.dataset.disabled && override("normal");
  else
    try {
      let [t, e] = [parent, self];
      for (;;) {
        if (t.port) {
          "true" === t.port.dataset.disabled
            ? (port.dataset.disabled = !0)
            : ((port.dataset.str = t.port.dataset.str), override("parent"));
          break;
        }
        if ((([e, t] = [t, t.parent]), e === t)) break;
      }
    } catch (e) {
      console.log(e);
    }
